<?php

namespace app\tpl\controller;
use think\Controller;

class Base extends Controller
{
    protected function _initialize()
    {
        $userInfo = session('user');
        if(!in_array(strtolower(request()->action()),['login','help','help1','license','noFind','register','error404']))
        {
            if(empty($userInfo))
            {
                if(request()->isAjax()){
                    exit(json_encode(['code'=>100,'msg'=>'登录超时，请重新登录！','data'=>'','success'=>false]));
                }else{
                    exit("<script>if(confirm('登录超时，是否重新登录？')){window.location.href = '/tpl/index/login';}</script>");
                }
            }
        }
    }
}